/*******************************************************
> Copyright (C) 2024 ==IOT== All rights reserved.
> File Name: stl_vector.cpp
> Author: IOT
> Website:www.slq.org
> Created Time: 2024年10月29日 星期二 16时22分29秒
***************************************************/

#include <iostream>
#include <vector> // 包含vector容器头文件

using namespace std;

void print_vector(vector<float>& arr);

int main(int argc,const char* argv[])
{
	vector<float> score(3, 60.0);
	cout << "size = " << score.size() << endl;
	cout << "capacity:" << score.capacity() << endl;
	
	score.push_back(70.1);
	
	cout << "size = " << score.size() << endl;
	cout << "capacity:" << score.capacity() << endl;
	
	score.push_back(80.5);
	
	cout << "size = " << score.size() << endl;
	cout << "capacity:" << score.capacity() << endl;
	score.push_back(90.5);
	score.push_back(93.5);
	cout << "size = " << score.size() << endl;
	cout << "capacity:" << score.capacity() << endl;
	
	
	float arr[3] = {87, 63, 45};
	
	score.insert(score.begin(), arr, arr + 2);
	print_vector(score);
	
	float sum = 0.0;
	for (int i = 0;i < score.size(); i++) {
		sum += score[i];
	}
	
	cout << "平均成绩：" << sum / score.size() << endl;
	
    return 0;
}

//
void print_vector(vector<float>& arr)
{
	int len = arr.size();
	for (int i = 0;i < len; i++)
		cout << arr[i] << " ";
	cout << endl;
}
